#! /usr/bin/python
import sys


if __name__ == '__main__':
	
	if len(sys.argv)==2:
		thread_runtime	= {}
		fp	= open(sys.argv[1], 'r')
		lineno	= 1;
		prevKey	= None
		for line in fp.readlines():
			splits	= line.strip().split()
			if (lineno % 3) == 1:
				if thread_runtime.has_key(int(splits[12])) is False:
					thread_runtime[int(splits[12])]	= [0.0, 0]
				prevKey	= int(splits[12])
			elif (lineno % 3) == 2:
				thread_runtime[prevKey][0]	= thread_runtime[prevKey][0] + float(splits[3]);
				thread_runtime[prevKey][1]	= thread_runtime[prevKey][1] + 1
			lineno	= lineno + 1
		
		for key in sorted(thread_runtime.iterkeys()):
			print key, thread_runtime[key][0]/thread_runtime[key][1]
				
	else:
		print 'Usage: ./stat.py [log file]'

